﻿using AutoClub.Core.Domain;
using AutoClub.Models;
using AutoMapper;

namespace AutoClub.Support
{
    /// <summary>
    /// Implementacion del mapeo utilizando automapper
    /// </summary>
    public class AutoModelMapper : IModelMapper
    {
        public AutoModelMapper()
        {
            Mapper.CreateMap<AddRaceModel, Race>()
                  .ForMember(dest => dest.Active, mo => mo.Ignore())
                  .ForMember(dest => dest.CreatedBy, mo => mo.Ignore())
                  .ForMember(dest => dest.CreatedOn, mo => mo.Ignore())
                  .ForMember(dest => dest.Id, mo => mo.Ignore())
                  .ForMember(dest => dest.State, mo => mo.Ignore());

        }

        #region IModelMapper members

        public TDestination Map<TSource, TDestination>(TSource source)
        {
            return Mapper.Map<TSource, TDestination>(source);
        }

        #endregion
    }
}